package org.ch02.test00.demo04;

import java.io.InputStream;
import java.lang.reflect.Method;

/**
 * @author ZQX
 * @date 2025-03-19
 */
public class MainTest {
    public static void main(String[] args) throws Exception {
        Class<?> scannerClass = Class.forName("java.util.Scanner");
        Object scanner = scannerClass.getConstructor(InputStream.class).newInstance(System.in);
        Method nextIntMethod = scannerClass.getMethod("nextInt");

        Object value = nextIntMethod.invoke(scanner);

        int yearInput = -1 ;
        if(value instanceof Integer) {
            yearInput = (int)value ;
        }

        Class<?> clz = Class.forName("org.ch02.test00.demo04.Year");
        Object object = clz.getConstructor(int.class).newInstance(yearInput);
        Method method = clz.getMethod("leapYear");

        String year = (String) method.invoke(object);
        System.out.println(year);
    }
}
